package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.Question;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IQuestionService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("question")
public class QuestionController {

    @Autowired
    private IQuestionService questionService;

    @RequestMapping("list")
    public String list(@ModelAttribute("qo") QueryObject qo, Model model){
        PageInfo<Question> result = questionService.query(qo);
        model.addAttribute("pageInfo", result);
        return "qna/questionlist";
    }

    @RequestMapping("delete")
    @ResponseBody
    public JSONResult delete(Long id){
        questionService.delete(id);
        return new JSONResult();
    }

}
